package com.tanhua.app.intercept;

import com.tanhua.model.pojo.User;

/**
 * ThreadLocal类。使用到的静态方法
 */
public class UserHolder {

    private static ThreadLocal<User> userThreadLocal = new ThreadLocal<>();

    //保存用户
    public static void set(User user){
        userThreadLocal.set(user);
    }

    //查询用户
    public static User get(){
        return userThreadLocal.get();
    }

    //查询用户id
    public static Long getUserId(){
        return userThreadLocal.get().getId();
    }

    //查询用户mobile
    public static String mobile(){
        return userThreadLocal.get().getMobile();
    }

    //移除用户
    public static void remove(){
        userThreadLocal.remove();
    }
}
